package com.ccp.dev.qbdms.service.impl;

import com.ccp.dev.core.basic.util.UUIDUtils;
import com.ccp.dev.core.basic.web.query.QueryFilter;
import com.ccp.dev.qbdms.dao.DemoDao;
import com.ccp.dev.qbdms.model.Demo;
import com.ccp.dev.qbdms.service.DemoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class DemoServiceImpl implements DemoService {

    @Resource
    private DemoDao demoDao;

    @Override
    public void addDemo(Demo demo) {
        String demoId = UUIDUtils.getUUIDFor32();
        demo.setDemoId(demoId);
        demo.setDemoTime(new Date());
        demoDao.add(demo);
    }

    @Override
    public void updateDemo(Demo demo) {
        demoDao.update(demo);
    }

    @Override
    public void deleteDemo(String demoId) {
        demoDao.delById(demoId);
    }

    @Override
    public List<Demo> pageDemo(QueryFilter queryFilter) {
        return demoDao.pageDemo(queryFilter);
    }

    @Override
    public Demo getDemo(String demoId) {
        return demoDao.getById(demoId);
    }
}
